package com.situ.team5.kzq.recruit.dao;

import com.situ.team5.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

//职位发表登记dao层
    @Mapper
public interface SalaryGrantDetailsDAO {
        //一级机构表全查
    @Select("select * from config_file_first_kind ")
    List<ConfigFileFirstKind> file_first_kindSelect();
    //  //通过一级机构表的id查询二级机构表
    @Select("select * from config_file_second_kind where first_kind_id=#{value}")
    List<ConfigFileSecondKind> file_second_kindSelectOne(int id);
        //对职位变更表的全查
    @Select("select k.second_kind_name,c.major_name, s.* from dbo.engage_major_release s inner join config_major c on s.major_id=c.major_id  " +
            "inner join config_file_second_kind k on s.second_kind_id=k.second_kind_id")
    List<Map> engage_major_releaseSelectAll();
    //对职位变更表通过id 进行查询
    @Select("select j.major_kind_name, i.third_kind_name,q.first_kind_name, k.second_kind_name,c.major_name, s.* from dbo.engage_major_release s " +
            "inner join config_major c on s.major_id=c.major_id  inner join config_file_second_kind k on s.second_kind_id=k.second_kind_id inner join" +
            " config_file_first_kind q on q.first_kind_id=s.first_kind_id inner join config_file_third_kind i on i.third_kind_id=s.third_kind_id inner join " +
            "config_major_kind j on j.major_kind_id=s.major_kind_id where mre_id=#{value}")
    Map EngageMajorReleaseupdate(Integer id);
    ////对职位变更表通过id 进行修改
    @Transactional
    @Update("update engage_major_release set  first_kind_id=#{first_kind_id},\n" +
            "second_kind_id=#{second_kind_id},third_kind_id=#{third_kind_id}, \n" +
            "engage_type=#{engage_type},major_id=#{major_id},human_amount=#{human_amount},\n" +
            "major_kind_id=#{major_kind_id},\n" +
            "deadline=#{deadline},changer=#{changer},change_time=#{change_time},\n" +
            "major_describe=#{major_describe} ,engage_required=#{engage_required}  where mre_id=#{mre_id}")
    void EngageMajorReleaseupdate2(EngageMajorRelease e);
    //查找与二级机构id有关的三级机构
    @Select("select * from config_file_third_kind where second_kind_id=#{value}")
    List<ConfigFileThirdKind> file_third_kindSelectOne(int id);
   //  //职位分类表全查做下拉框的
    @Select("select * from config_major_kind")
    List<ConfigMajorKind> config_major_kindSelect();
    //通过职位分类表id查询职位设置表
    @Select("select * from config_major where major_kind_id=#{value}")
    List<ConfigMajor> config_majorSelectOne(int id);
    @Transactional
    @Insert("insert into \n" +
        "\t\tengage_major_release (first_kind_id,second_kind_id,major_kind_id,third_kind_id,major_id,human_amount,engage_type,deadline,register,changer,regist_time,change_time,major_describe,engage_required) \n" +
        "\t\tvalues(#{first_kind_id},#{second_kind_id},#{major_kind_id},#{third_kind_id},#{major_id},#{human_amount},#{engage_type},#{deadline},#{register},#{changer},#{regist_time},#{change_time},#{major_describe},#{engage_required})")
    void EngageMajorReleaseInsert(EngageMajorRelease er);

    //职位发布查询的申请职位功能
    //对职位变更表通过id进行修改
    //@Transactional
    //@Update("update engage_major_release set  first_kind_id=#{first_kind_id},\n" +
    //        "second_kind_id=#{second_kind_id},third_kind_id=#{third_kind_id}, \n" +
     //       "engage_type=#{engage_type},major_id=#{major_id},human_amount=#{human_amount},\n" +
     //       "major_kind_id=#{major_kind_id},\n" +
      //      "register=#{register} where mre_id=#{mre_id}")
    //void EngageMajorReleaseupdate3(EngageMajorRelease e);
    @Transactional
    @Delete("delete from  engage_major_release where mre_id=#{mre_id} ")
    void engage_major_releaseDelete(int id);
}
